<?php
/**	
*	FILENAME: 		/server_app/authenticate_novasis.php
*	DESCRIPTION:	This script creates a valid JSON response after authenticating a user to NOVASIS.
*	AUTHOR:			Casey Burkhardt
*	VERSION:		1.0.0
*	LAST MODIFIED:	02/12/2010
**/

require_once($_SERVER['DOCUMENT_ROOT'] . "/libraries/novasis.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/libraries/functions.php");

enforceSSL();

$SID = $_POST["sid"];
$PIN = $_POST["pin"];

if (strlen($SID) == 0 || strlen($PIN) == 0) {
	// Inproper Data
	$response["response_type"] = "error";
	$response["error_desc"] = "Student ID or PIN not provided.";
	echo(json_encode($response));
} else if (getNOVASISSession($SID, $PIN) !== FALSE) {
	// Authenticated
	$response["response_type"] = "success";
	echo(json_encode($response));
} else {
	// Not Authenticaed
	$response["response_type"] = "error";
	$response["error_desc"] = "Invalid Username and Password.";
	echo(json_encode($response));
}